#include <bits/stdc++.h>
// 2025/03/01
// tag: 
// Author: Forever
using namespace std;

using int64 = int64_t;

#define int long long

int t, n, k, cnt[400001];

signed main()
{
    cin >> t;
    while (t--) {
        cin >> n >> k;
        memset(cnt, 0, sizeof(cnt));
        for (int i = 1; i <= n; i++) {
            int x;
            cin >> x;
            cnt[x]++;
        }
        int ans = 0;
        for (int i = 1; i * 2 < k; i++) 
            ans += min(cnt[i], cnt[k - i]);
        if (k % 2 == 0)
            ans += cnt[k / 2] / 2;
        cout << ans << endl;
    }
    return 0;
}